﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

<script src="scripts/Soapi.js" type="text/javascript"></script>

<script type="text/javascript">
    // demonstrate dates in / dates out
    // no need to deal with unix timestamps in Soapi.js

    // here are some date objects
    var fromDate = new Date("Tue, 1 Jun 2010 00:00:00");
    var toDate = new Date("Tue, 1 Jun 2010 01:00:00");

    // get some questions
    var route = new Soapi.RouteFactory("api.stackoverflow.com", "qgAq_KfDu0KYzlNG-qaTuw").Questions();

    // use min/max parameters with date objects
    // dates are converted to unix timestamps to build the url

    route.applyParameters({
        min: fromDate,
        max: toDate,
        sort: Soapi.Domain.PostSort.creation,
        pagesize: 1
    })
    .getResponse(function(data) {
        // unix timestamps are converted to Date in response before you get them
        alert("min/max\r\nThis date should be between Tue, 1 Jun 2010 00:00:00 and Tue, 1 Jun 2010 01:00:00 \r\n\r\n"
            + data.items[0].creation_date + "\r\n\r\n Dates In - Dates Out.\r\nNeat, huh?");
    }, function(error) { alert(error.message); });



    // use fromdate/todate parameters with date objects
    // dates are converted to unix timestamps to build the url

    route.applyParameters({
        fromdate: fromDate,
        todate: toDate,
        sort: Soapi.Domain.PostSort.creation,
        pagesize: 1
    })
    .getResponse(function(data) {
        // unix timestamps are converted to Date in response before you get them
        alert("fromdate/todate\r\nThis date should be between Tue, 1 Jun 2010 00:00:00 and Tue, 1 Jun 2010 01:00:00 \r\n\r\n"
            + data.items[0].creation_date + "\r\n\r\n Dates In - Dates Out.\r\nNeat, huh?");
    }, function(error) { alert(error.message); });        
    
</script>

</head>
<body>
</body>
</html>
